package com.java1412;

/**
 * @author java1412
 * @create 2022-09-21 16:48
 */
public class Test2 {
    public static void main(String[] args) {
        // t1:特需号
        // main：普通号
        MyRunnable t1 = new MyRunnable();
        t1.setPriority(10);
        Thread.currentThread().setPriority(5);
        t1.start();
        for (int i = 1; i <= 20; i++) {
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("普通号 : " + i + "号病人在看病!");
            if (i == 10) {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

class MyRunnable extends Thread {
    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            try {
                Thread.sleep(600);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("特需号 : " + i + "号病人在看病!");
        }
    }
}
